<template>
  <a-form-item :name="props.formNamePath" :label="formItem.label" :rules="[formItem.rule]" :extra="formItem.extra"
    :style="{ marginLeft: formItem.marginLeft + 'px' }" :class="formItem.associated
      ? 'form-a-radio-group_associated'
      : 'form-a-editor'
      ">
    <span class="beforeText upload-pic" v-if="formItem.beforeText">{{
      formItem.beforeText
    }}</span>
    <a-form-item-rest>
      <UEditor ref="editor" v-model="formItem.value"
        :options="{ initialFrameHeight: initialFrameHeight, initialFrameWidth: initialFrameWidth }"></UEditor>
    </a-form-item-rest>
    <div class="help-msg" v-if="formItem.helpMsg">
      {{ formItem.helpMsg }}
    </div>
  </a-form-item>
</template>

<script lang="ts" setup>
import { ref, reactive, watch, computed, defineExpose } from "vue"
import UEditor from "@/components/editor/UEditor.vue";
import { dataSourceType } from "@/type.d";
import { useColumnItem } from '@/components/draggable/hooks/useColumnModel';

//data
let initialFrameHeight = 420;
let initialFrameWidth = '100%';

//props
const props = defineProps({
  formItem: {
    type: Object,
    default: {} as dataSourceType,
  },
  formNamePath:[] as any
});
let editor = ref(null);
const formItem = ref(props.formItem as any);
useColumnItem(computed(() => props.formItem), formItem);
console.log(editor, 'editor');
defineExpose({ editor });
</script>

<style lang="less" scoped>
.help-msg {
  margin-top: 8px;
  font-size: 12px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.45);
  line-height: 20px;
}

.form-a-editor {
  ::v-deep(.ant-form-item-control) {
    // max-width: ''px !important;
  }
}
</style>
